const tool = require('../tools/tool')

module.exports = {
    AIModify: {
        getStatus: {
            exp: '查看AI完善状态',
            method: 'get',
            auth: {
                admin: true
            },
            async func(data) {
                return await tool.methods.question().AIModify.getStatus()
            }
        },
        start: {
            exp: '开始AI完善状态',
            method: 'post',
            auth: {
                admin: true
            },
            async func(data) {
                return await tool.methods.question().AIModify.start()
            }
        },
        reset: {
            exp: '重设全部题目的AI完善状态',
            method: 'post',
            auth: {
                admin: true
            },
            async func(data) {
                return await tool.methods.question().AIModify.resetAll()
            }
        },
    },
    AIParse: {
        add: {
            exp: '添加AI解析文档',
            method: 'post',
            auth: {
                admin: true
            },
            async func(data) {
                if (!data.param.fileName) throw '请提供题目文件'
                if (data.param.isEassy && !data.param.answerFileName) throw '请提供答案文件'
                tool.methods.question().AIParse.addDoc(data.param.fileName, data.param.answerFileName, data.param.paperName, data.param.categoryId, !!data.param.isEassy)
            }
        },
        getDisplay: {
            exp: '查看AI解析文档状态',
            method: 'get',
            auth: {
                admin: true
            },
            async func(data) {
                return await tool.methods.question().AIParse.getDisplay()
            }
        },
        deleteFinished: {
            exp: '删除已经完成解析的文件',
            method: 'post',
            auth: {
                admin: true
            },
            async func(data) {
                await tool.methods.question().AIParse.deleteFinished(data.param.id)
            }
        }
    }
}